<?php
class ServerTest{
    private $serv;
    public function __construct(){
        $this->serv = new swoole_http_server("127.0.0.1", 9502);
//         $this->serv->on('Request', function($request, $response) {
//             var_dump($request->get);
//             var_dump($request->post);
//             var_dump($request->cookie);
//             var_dump($request->files);
//             var_dump($request->header);
//             var_dump($request->server);
        
//             $response->cookie("User", "Swoole");
//             $response->header("X-Server", "Swoole");
//             $response->end("<h1>Hello Swoole!</h1>");
//         });
        $this->serv->on('Request', array($this, 'onRequest'));
        $this->serv->start();
    }
    
    public function onRequest($request, $response){
        var_dump($request->get);
        var_dump($request->post);
        var_dump($request->cookie);
        var_dump($request->files);
        var_dump($request->header);
        var_dump($request->server);
        
        $response->cookie("User", "Swoole");
        $response->header("X-Server", "Swoole");
        $response->end("<h1>Hello Swoole!</h1>");
    }
}

$serv = new ServerTest();